package cn.firecode.data_collect.utils;

import lombok.Data;

/**
 * @author: yangfan
 * @Date: 2019/12/10
 * @Description:
 */
@Data
public class DataResponse {

    private int status;
    private String msg;
    private Object data;

    public static final DataResponse LOGIN_ERROR = new DataResponse(1,"用户名或密码错误");

    public DataResponse(){
        super();
    }
    public DataResponse(int status, String msg){
        this.status = status;
        this.msg = msg;
    }
    public DataResponse(int status, Object data){
        this.status = status;
        this.data = data;
    }

    public static DataResponse succeed(String msg, Object data){
        DataResponse response = new DataResponse();
        response.status = 0 ;
        response.msg = msg;
        response.data = data;
        return response;
    }

    public static DataResponse succeed(String msg){
        DataResponse response = new DataResponse();
        response.status = 0 ;
        response.msg = msg;
        response.data = "";
        return response;
    }

    public static DataResponse succeed(Object data){
        DataResponse response = new DataResponse();
        response.status = 0 ;
        response.data = data;
        return response;
    }

    public static DataResponse failed(int statusCode, String msg){
        DataResponse response = new DataResponse();
        response.status = statusCode;
        response.msg = msg;
        response.data = "";
        return response;
    }

    public static DataResponse failed(int statusCode, Object data){
        DataResponse response = new DataResponse();
        response.status = statusCode;
        response.data = data;
        return response;
    }
    public static DataResponse failed(int statusCode, String msg, Object data){
        DataResponse response = new DataResponse();
        response.status = statusCode;
        response.msg = msg;
        response.data = data;
        return response;
    }


}
